<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>v-for循环</title>
    <script src="../lib/vue.js"></script>
</head>
<body>
    <div id="app">
        id:<input v-model="id" />
        name:<input v-model="name" />
        <input type="button" @click="add" value="添加" />
        <p v-for="(user,i) in users" :key="user.id">
            <input type="checkbox" />
            id为：{{user.id}} ----姓名为：{{user.name}}
        </p>

    </div>

    <script>
        var vue = new Vue({
            el:'#app',
            data:{
                id:'',
                name:'',
                users:[
                    {id:1,name:'zs'},
                    {id:2,name:'zs1'},
                    {id:3,name:'zs2'},
                    {id:4,name:'zs3'}
                ]
            },
            methods:{
                add(){
                    // this.users.push({id:this.id,name:this.name});

                    this.users.unshift({id:this.id,name:this.name})
                }
            }
        });
    </script>
</body>
</html>